package com.mq.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mq.domain.SysDept;
import com.mq.domain.SysUser;
import com.mq.mapper.SysDeptMapper;
import com.mq.mapper.SysUserMapper;
import com.mq.service.SendDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gxd
 * @since 2025/6/8
 */
@Slf4j
@RestController
public class SendUserController {

    @Autowired
    private SendDataService sendDataService;

    @Autowired
    private SysUserMapper userMapper;

    @Autowired
    private SysDeptMapper deptMapper;

    // 发送用户数据
    @GetMapping("/sendUserData")
    public void sendUserData() {
        List<SysUser> sysUsers = userMapper.selectList(Wrappers.lambdaQuery(SysUser.class).eq(SysUser::getDeleted, 0));
        sendDataService.sendUserData(sysUsers);
    }

    // 发送部门数据
    @GetMapping("/sendDeptData")
    public void sendDeptData() {
        List<SysDept> sysDepts = deptMapper.selectList(Wrappers.lambdaQuery(SysDept.class).eq(SysDept::getDeleted, 0));
        sendDataService.sendDeptData(sysDepts);
    }
}
